package com.taozi.netty.socketio.use.classroomchat.utils;

import lombok.extern.slf4j.Slf4j;

import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;

/**
 *  字符串处理
 *
 * @author mingtao
 */
@Slf4j
public class CpssStringUtils {

    /**
     * @description 将中文转码，为了兼容IE9接收中文乱码问题
     * @param str
     * @return java.lang.String
     * @author mingtao
     * @date 15:01 2019/7/8
     **/
    public static String toStringUtf8(String str){
        String result = null;
        try {
            result = URLEncoder.encode(str, "utf-8");
        } catch (UnsupportedEncodingException e) {
            log.error("编码失败：{}", e);
            e.printStackTrace();
        }
        return result;
    }

}
